from sklearn.datasets import make_circles
import matplotlib.pylab as plt
x,y=make_circles(n_samples=3000,factor=0.3,noise=0.05)
plt.scatter(x[:,0],x[:,1])
plt.show()

#使用2个质心的kmeans算法
from sklearn.cluster import KMeans
model1 = KMeans(n_clusters=2)
y_pred = model1.fit_predict(x)
plt.scatter(x[:,0],x[:,1],c=y_pred)
plt.show()

#使用邻域为0.2的DBSCAN算法
from sklearn.cluster import DBSCAN
y_pred2 = DBSCAN(eps=0.2).fit_predict(x)
plt.scatter(x[:,0],x[:,1],c=y_pred2)
plt.show()
